home *** CD-ROM | disk | FTP | other *** search
/ Enter 2003: The Beautiful Scenery / enter-parhaat-2003.iso / files / frendz.exe / frendz.dcr / Scripts_5_Progress Bar for Streaming Movies.ls < prev    next >
Encoding:
Text File  |  2002-12-31  |  3.8 KB  |  110 lines

  1. property url, pBarWidth, statList, percentDone, pBarConverter, showPercent, percentMember, currentSprite, percentText, showText, pDoneLoading
  2.  
  3. on getPropertyDescriptionList
  4.   casts = []
  5.   textList = []
  6.   numLibs = the number of castLibs
  7.   repeat with i = 1 to numLibs
  8.     add(casts, castLib(i).name)
  9.   end repeat
  10.   repeat with n = 1 to count(casts)
  11.     castToCheck = getAt(casts, n)
  12.     numMems = the number of castMembers of castLib castToCheck
  13.     repeat with x = 1 to numMems
  14.       m = member(x, n)
  15.       case m.type of
  16.         #text, #field:
  17.           if m.name = EMPTY then
  18.             add(textList, m)
  19.           else
  20.             add(textList, m.name)
  21.           end if
  22.       end case
  23.     end repeat
  24.   end repeat
  25.   description = [:]
  26.   if textList <> [] then
  27.     addProp(description, #showPercent, [#comment: "Enable Display of Percent Loaded:", #format: #boolean, #default: 0])
  28.     addProp(description, #percentMember, [#comment: "Display Percent Loaded in Member:", #format: #string, #range: textList, #default: getAt(textList, 1)])
  29.   end if
  30.   return description
  31. end
  32.  
  33. on beginSprite me
  34.   showText = 0
  35.   casts = []
  36.   textList = []
  37.   numLibs = the number of castLibs
  38.   repeat with i = 1 to numLibs
  39.     add(casts, castLib(i).name)
  40.   end repeat
  41.   repeat with n = 1 to count(casts)
  42.     castToCheck = getAt(casts, n)
  43.     numMems = the number of castMembers of castLib castToCheck
  44.     repeat with x = 1 to numMems
  45.       m = member(x, n)
  46.       case m.type of
  47.         #text, #field:
  48.           if m.name = EMPTY then
  49.             add(textList, m)
  50.           else
  51.             add(textList, m.name)
  52.           end if
  53.       end case
  54.     end repeat
  55.   end repeat
  56.   if textList <> [] then
  57.     showText = 1
  58.   end if
  59.   floatPrecision = 2
  60.   pDoneLoading = 0
  61.   currentSprite = me.spriteNum
  62.   pBarWidth = sprite(currentSprite).width
  63.   pBarConverter = float(pBarWidth) / 100
  64.   url = the moviePath & the movieName
  65.   sprite(currentSprite).width = 0
  66.   percentText = "0%"
  67.   CheckStatus(me)
  68. end
  69.  
  70. on exitFrame me
  71.   CheckStatus(me)
  72.   if pDoneLoading = 1 then
  73.     go(3)
  74.     pDoneLoading = 0
  75.   end if
  76. end
  77.  
  78. on CheckStatus me
  79.   statList = getStreamStatus(url)
  80.   if statList.state <> "Complete" then
  81.     if statList.bytesSoFar > 0 then
  82.       set the floatPrecision to 0
  83.       percentDone = statList.bytesSoFar * 100.00010000000000332 / statList.bytesTotal
  84.       percentDone = float(percentDone)
  85.       sprite(currentSprite).width = integer(percentDone * pBarConverter)
  86.       percentText = percentDone & "%"
  87.     else
  88.       sprite(currentSprite).width = 0
  89.       percentText = "0%"
  90.     end if
  91.   else
  92.     sprite(currentSprite).width = pBarWidth
  93.     percentText = "100%"
  94.     pDoneLoading = 1
  95.   end if
  96.   if showText = 1 then
  97.     if (percentText <> member(percentMember).text) and showPercent then
  98.       member(percentMember).text = percentText
  99.     end if
  100.   end if
  101. end
  102.  
  103. on getBehaviorDescription
  104.   return "What the behavior does:" & RETURN & RETURN & "Turns a sprite into a progress bar, indicating progress of the current movie's stream." & RETURN & RETURN & RETURN & "How to use:" & RETURN & RETURN & "1. Drag and drop this behavior on to the sprite that should act as the progress bar." & RETURN & RETURN & "2. Display Percent Downloaded (Optional)." & RETURN & RETURN & "If a field or text castmember is detected in one of the movie's casts, there is an additional option to display the percent downloaded of the movie.  Check the checkbox provided to enable display of percent downloaded, and select the castmember that should be used to display the percent."
  105. end
  106.  
  107. on getBehaviorTooltip
  108.   return "Use this to create an animating" & RETURN & "progress bar for a streaming movie." & RETURN & "Drop it on the sprite that will be" & RETURN & "used as the progress bar." & RETURN & RETURN & "If a field or text castmember exists," & RETURN & "there is an additional option to display" & RETURN & "the percent of the movie that has been" & RETURN & "downloaded."
  109. end
  110.